package com.tdzh.maimaiti.view;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.tdzh.maimaiti.R;

public class IsFirstRunActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_is_first_run);

        SharedPreferences sharedata = getSharedPreferences("fristrun", Context.MODE_PRIVATE);
        Boolean isFirst = sharedata.getBoolean("isFirst", true);

        if(isFirst){
           // SharedPreferences sharedata = getSharedPreferences("fristrun", Context.MODE_PRIVATE);
            System.out.println("you first run this app");
            Intent intent = new Intent(IsFirstRunActivity.this,LoginActivity.class);
            startActivity(intent);
        }else{
            Intent intent = new Intent(IsFirstRunActivity.this,MainActivity.class);
            startActivity(intent);
        }

      /*  SharedPreferences mySharedPreferences= getSharedPreferences("test",
               0);
      //实例化SharedPreferences.Editor对象（第二步）
        SharedPreferences.Editor editor = mySharedPreferences.edit();
      //用putString的方法保存数据
        editor.putString("name", "Karl");
        editor.putString("habit", "sleep");
    //提交当前数据
        editor.commit();
//使用toast信息提示框提示成功写入数据
        Toast.makeText(this, "数据成功写入SharedPreferences！", Toast.LENGTH_LONG).show()*/;
    }
}
